/*
* $Id: LetterDraw.cpp 24 2010-02-03 16:23:48Z volok-aleksej@yandex.ru $
*
* Copyright 2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "LetterDraw.h"

CLetterDraw::CLetterDraw(TCHAR nChar)
:m_char(nChar), m_bSel(false), m_rect(0, 0, 0, 0){
	HDC dc = GetDC(GetDesktopWindow());
	CSize size;
	GetTextExtentPoint(dc, &nChar, 1, &size);
	if(nChar == '\n')
		size.cx = 0;
	DeleteDC(dc);
	m_rect.SetRect(0, 0, size.cx, size.cy);
}
CLetterDraw::~CLetterDraw(){}

void CLetterDraw::Paint(CDC* dc){
	if(m_bSel){
		dc->SetBkMode(BKMODE_LAST);
		dc->SetBkColor(RGB(0, 0, 255));
		dc->SetTextColor(RGB(255, 255, 255));
	}else{
		dc->SetBkMode(TRANSPARENT);
		dc->SetTextColor(RGB(0, 0, 0));
	}
	std::tstring str(&m_char, 1);
	dc->DrawText(str.c_str(), m_rect, DT_CENTER);
	dc->SetTextColor(RGB(0, 0, 0));
}

void CLetterDraw::SetBeginPoint(CPoint point){
	m_rect.MoveToXY(point);
}
CRect CLetterDraw::GetRect(){
	return m_rect;
}
void CLetterDraw::SetSel(bool bSel){
	m_bSel = bSel;
}
bool CLetterDraw::IsSel(){
	return m_bSel;
}